package lesson11;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class TestFrame02 extends JFrame {
    private JButton btn1 = new JButton("按钮1");
    private JButton btn2 = new JButton("按钮2");
    public TestFrame02(){
        this.setLayout(null);

        btn1.setBounds(0,0,100,30);
        btn1.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("按钮1鼠标点击");
            }
        });
        btn2.setBounds(110,0,100,30);
        btn2.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("按钮2鼠标点击");
            }
        });
        this.add(btn1);
        this.add(btn2);



        this.setSize(800,600);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new TestFrame02();
    }

}
